from django.db import models
import uuid

#用户权限表
class Root(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.TextField(max_length=10)

    def __str__(self):
        return "<Root:id=%s,name=%s>"\
            %(self.id,self.name)

#用户表
class UserInfo(models.Model):
    id = models.UUIDField(primary_key=True,default = uuid.uuid1().hex)
    user_nickname = models.TextField()
    user_name = models.TextField(max_length=10)
    user_psd = models.TextField(max_length=10)
    user_mail = models.TextField()
    root = models.ForeignKey(Root,on_delete=models.CASCADE)

    def __str__(self):
        return "<UserInfo:id=%s,user_name=%s,user_psd=%s,user_mail=%s,user_nickname=%s>"\
            %(self.id,self.user_name,self.user_psd,self.user_mail,self.user_nickname)
